/*
 * Created by Christopher King
 * Copyright (C) 2007 Christopher King, All Rights Reserved.
 */

package us.cirion.adventure.engine.prerequisite;

import us.cirion.adventure.engine.Noun;
import us.cirion.adventure.engine.Nowhere;
import us.cirion.adventure.engine.PreRequisite;

/**
 * Requires that an item exists somewhere within the game world.
 * 
 * @author Chris
 */
public class ItemExists implements PreRequisite
{

	private Noun item;

	/**
	 * Constructs a new condition for item existence.
	 * 
	 * @param item The noun that must exist.
	 */
	public ItemExists(Noun item)
	{
		this.item = item;
	}

	/**
	 * Indicates whether the item exists. An item exists if it has a location
	 * other than "nowhere".
	 * 
	 * @return <code>true</code> if the item exists, <code>false</code>
	 *         otherwise.
	 */
	public boolean isSatisfied()
	{
		return !item.getLocation().equals(Nowhere.getInstance());
	}

}
